﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;

    public class ConfigurationFilter : IFilter
    {
        public void DoFilter(FilterChain chain)
        {
            string url = chain.Request.AppRelativeCurrentExecutionFilePath;
            List<string> roleUrllist = new List<string>();
            bool IsPass = false;
            url = url.Substring(url.IndexOf('/'), url.IndexOf('.') - url.IndexOf('/'));
            if (chain.Url.Contains(".aspx"))
            {
                if ((chain.Request.QueryString["functionGID"] != null) && (chain.Request.QueryString["functionGID"].ToString() != ""))
                {
                    chain.Session["NavigatorSelectedValue"] = chain.Request.QueryString["functionGID"].ToString();
                }
                if (chain.Session["User"] != null)
                {
                    if (chain.Url.Contains("aspx?actionid="))
                    {
                        IsPass = true;
                    }
                    if (!IsPass)
                    {
                        chain.Response.Redirect("~/RoleError.htm");
                        return;
                    }
                }
                else
                {
                    chain.Response.Write("<script language=javascript>parent.parent.location.href='Login.aspx'</script>");
                    chain.Response.End();
                    return;
                }
            }
            chain.DoFilter();
        }
    }
}

